#pragma region License
/*
MIT License
Copyright © 2006 The Mono.Xna Team

All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma endregion License

#ifndef CurveKeyCollection_h
#define CurveKeyCollection_h

#include <System/RObject.h>
#include <System/RString.h>
#include <System/RArray.h>
#include <System/IEquatable.h>

#include "RMathHelper.h"


namespace Riccsson
{
	namespace Xna
	{
		namespace Framework
		{
			class CurveKeyCollection
				: ICollection<CurveKey>
				, IEnumerable<CurveKey>
				, IEnumerable
			{
				#pragma region private: Fields

				private: bool isReadOnly = false;
				private: List<CurveKey> innerlist;

				#pragma endregion private: Fields


				#pragma region Properties

				public PROP3_GET(int, Count)
				{
					return innerlist.Count;
				}

				public PROP3_GET(bool, IsReadOnly)
				{
					return this->isReadOnly;
				}

				//public CurveKey this[int index]
				//{
				//	get { return innerlist[index]; }
				//	set
				//	{
				//		if (value == null)
				//			throw new ArgumentNullException();
                //
				//		if (index >= innerlist.Count)
				//			throw new IndexOutOfRangeException();
                //
				//		if (innerlist[index].Position == value.Position)
				//			innerlist[index] = value;
				//		else
				//		{
				//			innerlist.RemoveAt(index);
				//			innerlist.Add(value);
				//		}
				//	}
				//}

				#pragma endregion Properties


				#pragma region Constructors

				public CurveKeyCollection()
				{
					innerlist = new Riccsson::System::Collections::Generic::List<CurveKey>();
				}

				#pragma endregion Constructors


				#pragma region Public Methods

				public void Add(CurveKey* item)
				{
					if (item == null)
						throw Riccsson::System::ArgumentNullException();

					if (innerlist.Count == 0)
					{
						this->innerlist.Add(item);
						return;
					}

					for (int i = 0; i < this->innerlist.Count; i++)
					{
						if (item.Position < this->innerlist[i].Position)
						{
							this->innerlist.Insert(i, item);
							return;
						}
					}

					this->innerlist.Add(item);
				}

				public void Clear()
				{
					innerlist.Clear();
				}
				
				public GC_PTR<CurveKeyCollection> Clone()
				{
					CurveKeyCollection ckc = new CurveKeyCollection();
					foreach (CurveKey* key in this->innerlist)
						ckc->Add(key);
					return ckc;
				}
				
				public bool Contains(CurveKey* item)
				{
					return innerlist.Contains(item);
				}
				
				public void CopyTo(Riccsson::System::Array<CurveKey>* array, int arrayIndex)
				{
					innerlist.CopyTo(array, arrayIndex);
				}
				
				public IEnumerator<CurveKey> GetEnumerator()
				{
					return innerlist.GetEnumerator();
				}
				
				public int IndexOf(CurveKey item)
				{
					return innerlist.IndexOf(item);
				}
				
				public bool Remove(CurveKey item)
				{
					return innerlist.Remove(item);
				}
				
				public void RemoveAt(int index)
				{
					innerlist.RemoveAt(index);
				}

				IEnumerator IEnumerable.GetEnumerator()
				{
					return innerlist.GetEnumerator();
				}

				#pragma endregion Public Methods
			};
		}
	}
}

#endif